package com.atguigu.springcloud.service.impl;

import com.atguigu.springcloud.service.IMessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;


import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author liuzemin
 * @date 2020/12/2 12:46
 * @description
 */
@EnableBinding(Source.class)
public class MessageProvider implements IMessageProvider {
    @Autowired
    @Qualifier(value = "output")
    private MessageChannel messageChannel;

    @Override
    public String send() {
        String s = UUID.randomUUID().toString();
        messageChannel.send(MessageBuilder.withPayload(s).build());
        System.out.println("++++++message+++++    "+s);
        return null;
    }
}
